package main

import (
	"encoding/json"
	"fmt"
	"log"
	"os"
)

func main() {
	fmt.Println("Hello, World!")
	file, _ := os.Create("json.txt")
	var countryCapitalMap map[string]string
	/* 创建集合 */
	countryCapitalMap = make(map[string]string)

	/* map 插入 key-value 对，各个国家对应的首都 */
	countryCapitalMap["France"] = "Paris"
	countryCapitalMap["Italy"] = "Rome"
	countryCapitalMap["Japan"] = "Tokyo"
	countryCapitalMap["India"] = "New Delhi"
	v := countryCapitalMap
	enc := json.NewEncoder(file)
	err := enc.Encode(v)
	if err != nil {
		log.Fatal(err)
	}
	file.Close()
}
